<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="8" >
            <a-form-model-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="date">
              <g-year-picker
                placeholder="请选择时间"
                :is-init="false"
                v-model="model.date"
              ></g-year-picker>
            </a-form-model-item>
          </a-col>
          <a-col :span="8" >
            <a-form-model-item label="级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jxmsClassess">
              <j-dict-select-tag type="list" v-model="model.jxmsClassess" dictCode="JXMS_CLASSESS" placeholder="请选择级别"  @change="getTotalScore"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="总分" :labelCol="{ span: 6 }" :wrapperCol="{ span: 16 }" prop="totalScore">
              <a-input v-model="model.totalScore" placeholder="请输入名称" :disabled="true"></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="8">
            <a-form-model-item label="教师" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teacherId">
              <j-select-user-by-dep  v-model="model.teacherId" @change="(...args)=>{selectedUser(...args)}" :multi="false"></j-select-user-by-dep>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="教工编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input placeholder="教工编号" v-model="model.teacherId" :disabled="true"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="积分学院" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgId_dictText">
              <teaching-depart v-model="model.orgId"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="备注" :labelCol="{ span: 2 }" :wrapperCol="{ span: 22 }" prop="remark">
              <a-input  v-model="model.remark" placeholder="请输入备注" :rows="3" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>

  </a-spin>
</template>

<script>
import { getAction } from '@/api/manage'
import GYearPicker from '@views/gfxy/common/GYearPicker'
import moment from 'moment'
import {GfxyOneToOneMixin} from '@/mixins/GfxyOneToOneMixin'
import { GfxyMemberListMixin } from '@/mixins/GfxyMemberListMixin'
import TeachingDepart from '@comp/gfxy/TeachingDepart.vue'
  export default {
    name: 'JxmsForm',
    mixins:[GfxyOneToOneMixin],
    components: {GYearPicker,TeachingDepart} ,

    data() {
      return {

        confirmLoading : false,
        // 新增时子表默认添加几行空数据

        validatorRules: {
          date: [
            { required: true, message: '请输入时间!'},
          ],
          jxmsClassess: [
            { required: true, message: '请输入级别!'},
          ],
          teacherId: [
            { required: true, message: '请选择教师!'},
          ],

        },

        url: {
          add: "/teaching/jxms/add",
          edit: "/teaching/jxms/edit",
          queryById: "/teaching/jxms/queryById",
          getTotalScore: "teaching/jxms/getTotalScore",
          memberList: {
            list: '/teaching/jxms/queryMemberListByMainId'
          },

        }
      }
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      },
      itemValue:{
        type: Number,
        required: true,
      },
      date:{
        type: String,
        required: true,
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
    },
    methods: {

      getTotalScore() {

        if (this.model.jxmsClassess != undefined) {
          this.confirmLoading = true;
          getAction(this.url.getTotalScore, { jxmsClassess: this.model.jxmsClassess }).then((res) => {
            if (res.success) {
              this.model.totalScore = res.result;
            }
            if(res.code===510){
              this.$message.warning(res.message)
            }
            this.confirmLoading = false;
          })
        }
      },

    }



  }
</script>

<style scoped>
</style>